home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / utility / sml-mode-3.3b / sml-menus.el < prev    next >
Encoding:
Text File  |  1997-08-18  |  5.6 KB  |  146 lines  |  [TEXT/R*ch]

  1. ;;; sml-menus.el. Simple menus for sml-mode
  2.  
  3. ;; Copyright (C) 1994, Matthew J. Morley
  4.  
  5. ;; This file is not part of GNU Emacs, but it is distributed under the
  6. ;; same conditions.
  7.  
  8. ;; ====================================================================
  9.  
  10. ;; This program is free software; you can redistribute it and/or
  11. ;; modify it under the terms of the GNU General Public License as
  12. ;; published by the Free Software Foundation; either version 2, or (at
  13. ;; your option) any later version.
  14.  
  15. ;; This program is distributed in the hope that it will be useful, but
  16. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. ;; General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  22. ;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24. ;; ====================================================================
  25.  
  26. ;;; DESCRIPTION
  27.  
  28. ;; You need auc-menu or easymenu on your lisp load-path.
  29.  
  30. ;; Menus appear only when the cursor is in an sml-mode buffer. They
  31. ;; should appear automatically as long as sml-mode can find this file
  32. ;; and easymenu.el (or auc-menu.el), but not otherwise.
  33.  
  34. ;; If you load sml-proc.el to run an inferior ML process -- or even a
  35. ;; superior one, who knows? -- the "Process" submenu will become active.
  36.  
  37. ;;; CODE 
  38.  
  39. (condition-case () (require 'easymenu) (error (require 'auc-menu)))
  40.  
  41. ;; That's FSF easymenu, distributed with GNU Emacs 19, or Per
  42. ;; Abrahamsen's auc-menu distributed with AUCTeX, or from the Emacs
  43. ;; lisp archive, or the IESD (ftp://sunsite.auc.dk/packages/auctex/)
  44. ;; lisp archive at Aalborg (auc-menu works with XEmacs too).
  45.  
  46. (defconst sml-menu
  47.   (list ;"SML"
  48.         (list "Process"
  49.               ["Start default ML compiler"  sml
  50.                 :active (fboundp 'sml)]
  51.               ["-" nil nil]
  52.               ["load ML source file"        sml-load-file 
  53.                 :active (featurep 'sml-proc)]
  54.               ["switch to ML buffer"        switch-to-sml
  55.                 :active (featurep 'sml-proc)]
  56.               ["--" nil nil]
  57.               ["send buffer contents"       sml-send-buffer 
  58.                 :active (featurep 'sml-proc)]
  59.               ["send region"                sml-send-region 
  60.                 :active (featurep 'sml-proc)]
  61.               ["send paragraph"             sml-send-function 
  62.                 :active (featurep 'sml-proc)]
  63.               ["goto next error"            sml-next-error 
  64.                 :active (featurep 'sml-proc)]
  65.               ["---" nil nil]
  66.               ["Standard ML of New Jersey"  sml-smlnj
  67.                 :active (fboundp 'sml-smlnj)]
  68.               ["Poly/ML"                    sml-poly-ml
  69.                 :active (fboundp 'sml-poly-ml)]
  70.               ["Moscow ML"                  sml-mosml
  71.                 :active (fboundp 'sml-mosml)]
  72.               ["Help for Inferior ML"   (describe-function 'inferior-sml-mode) 
  73.                 :active (featurep 'sml-proc)]
  74.               )
  75.         ["electric pipe"     sml-electric-pipe t]
  76.         ["insert SML form"   sml-insert-form t]
  77.         (list "Forms" 
  78.               ["abstype"     sml-form-abstype t]
  79.               ["datatype"    sml-form-datatype t]
  80.               ["-" nil nil]
  81.               ["let"         sml-form-let t]
  82.               ["local"       sml-form-local t]
  83.               ["case"        sml-form-case t]
  84.               ["--" nil nil]
  85.               ["signature"   sml-form-signature t]
  86.               ["functor"     sml-form-functor t]
  87.               ["structure"   sml-form-structure t])
  88.         (list "Format/Mode Variables"
  89.               ["indent region"             sml-indent-region t]
  90.               ["outdent"                   sml-back-to-outer-indent t]
  91.               ["-" nil nil]
  92.               ["set indent-level"          sml-indent-level t]
  93.               ["set pipe-indent"           sml-pipe-indent t]
  94.               ["--" nil nil]
  95.               ["toggle type-of-indent"     (sml-type-of-indent) t]
  96.               ["toggle nested-if-indent"   (sml-nested-if-indent) t]
  97.               ["toggle case-indent"        (sml-case-indent) t]
  98.               ["toggle electric-semi-mode" (sml-electric-semi-mode) t])
  99.         ["-----" nil nil]
  100.         ["SML mode help (brief)"       describe-mode t]
  101.         ["SML mode *info*"             sml-mode-info t]
  102.         ["SML mode version"            sml-mode-version t]
  103.         ["-----" nil nil]
  104.         ["Fontify buffer"    (sml-mode-fontify-buffer)
  105.                 :active (or (featurep 'sml-font) (featurep 'sml-hilite))]
  106.         ["Remove overlay"    (sml-error-overlay 'undo)
  107.                 :active (sml-overlay-active-p)]
  108.         ))
  109.  
  110. (defun sml-mode-fontify-buffer ()
  111.   "Just as it suggests."
  112.   (cond ((featurep 'sml-font) 
  113.          (font-lock-fontify-buffer))
  114.         ((featurep 'sml-hilite) 
  115.          (hilit-rehighlight-buffer))
  116.         (t
  117.          (message "No highlight scheme specified")))) ; belt & braces
  118.  
  119. (easy-menu-define sml-mode-menu
  120.     sml-mode-map
  121.     "Menu used in sml-mode."
  122.     (cons "SML" sml-menu))
  123.  
  124. ;;; Make's sure they appear in the menu bar when sml-mode-map is active.
  125.  
  126. ;; On the hook for XEmacs only -- see easy-menu-add in auc-menu.el.
  127.  
  128. (defun sml-mode-menu-bar ()
  129.   "Make sure menus appear in the menu bar as well as under mouse 3."
  130.   (and (eq major-mode 'sml-mode)
  131.        (easy-menu-add sml-mode-menu sml-mode-map)))
  132.  
  133. (add-hook 'sml-mode-hook 'sml-mode-menu-bar)
  134.  
  135. ;; Autoload all the process code if these are selected.
  136.  
  137. (autoload 'sml "sml-proc" sml-no-doc t)
  138.  
  139. ;; Not these two.
  140. ;; (autoload 'sml-poly-ml "sml-poly-ml" sml-no-doc t) 
  141. ;; (autoload 'sml-mosml "sml-mosml" sml-no-doc t) 
  142.  
  143. (provide 'sml-menus)
  144.  
  145. ;;; sml-menu.el is over now.
  146.